﻿package com.gengine.resource.loader
{
    import flash.utils.*;

    public class XMLLoader extends BaseLoader
    {
        private var _valid:Boolean = true;
        private var _xml:XML = null;

        public function XMLLoader()
        {
            return;
        }// end function

        public function get XMLData() : XML
        {
            return this._xml;
        }// end function

        override public function getClass() : Class
        {
            return XMLLoader;
        }// end function

        override public function initialize(param1) : void
        {
            var data:* = param1;
            if (!(data is ByteArray))
            {
                throw new Error("XMLResource can only initialize from ByteArrays.");
            }
            try
            {
                this._xml = new XML(data.toString());
                if (resourceInfo)
                {
                    resourceInfo.data = this._xml;
                }
            }
            catch (e:TypeError)
            {
                _valid = false;
            }
            onLoadCompleteHandler();
            return;
        }// end function

        override protected function onContentReady(param1) : Boolean
        {
            return this._valid;
        }// end function

    }
}
